﻿using DAL;
using MODEL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BLL
{
    public class TruckBLL
    {
        //调用DAL层的车辆信息
        TruckDAL truck = new TruckDAL();

        #region 多条语句查询,车辆信息
        /// <summary>
        /// 多条语句查询
        /// </summary>
        /// <param name="querymodel"></param>
        /// <returns></returns>
        public List<TruckMODEL> GetTruckList(TruckTeamQueryModel querymodel)
        {
            return truck.GetTruckList(querymodel);
        }
        #endregion

        #region 删除信息，车辆信息进行修改式删除,1删除成功，0删除失败，-1已删除
        /// <summary>
        /// 删除信息，车辆信息进行修改式删除
        /// </summary>
        /// <param name="delete"></param>
        /// <returns></returns>
        public int DeleteTruckList(int id)
        {
            TruckUpdateModel model = truck.GetDeleteTruckByID(id);
            if (model.IsDelete)
            {
                return -1;
            }
            int result = truck.DeleteTruckList(id);
            if (result > 0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
            //return tr.DeleteTruckList(id);
        }
        #endregion

        #region 删除车辆信息根据id
        /// <summary>
        /// 删除车辆信息根据id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public TruckUpdateModel GetDeleteTruckByID(int id)
        {
            return truck.GetDeleteTruckByID(id);
        }
        #endregion

        #region 添加车辆信息
        /// <summary>
        /// 添加车辆信息
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public int UInsertTruck(TruckTeamQueryModel sql)
        {
            return truck.UInsertTruck(sql);
        }
        #endregion

        #region 修改编辑车辆信息
        /// <summary>
        /// 修改车辆信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateTruck(TruckMODEL model)
        {
            return truck.UpdateTruck(model);
        }
        #endregion

        #region 根据ID进行车辆信息修改
        /// <summary>
        /// 根据ID获取编辑车队信息
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public TruckMODEL GetUpdateTruckID(int teamid)
        {
            return truck.GetUpdateTruckID(teamid);
        }
        #endregion

        /// <summary>
        /// 分页存储过程，车辆信息
        /// </summary>
        /// <param name="number"></param>
        /// <param name="type"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCout"></param>
        /// <returns></returns>
        public List<TruckMODEL> GetPagerTruckList(string number,  int pageIndex, int pageSize, out int totalCout)
        {
            //string type,   type,
            return truck.GetPagerTruckList(number,  pageIndex, pageSize, out totalCout);
        }
        }
}
